////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011-2012 www.iflytek.com. All Rights Reserved.
//  This software for customer relationship management system, developed by Iflytek-ZY-GCZX team.
//  Software code and design for the team, copy rights reserved.
////////////////////////////////////////////////////////////////////////////////

package com.iflytek.ci.cums.dao.impl;

import java.util.List;

import com.iflytek.ci.cums.dao.AccountDao;
import com.iflytek.ci.cums.dao.UserBatchDao;
import com.iflytek.ci.cums.domain.Account;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 帐号相关批处理操作DAO.
 * </p>
 *
 * @author poplar.yfyang
 * @version 1.0 2012-11-18 2:34 PM
 * @since JDK 1.5
 */
@Repository("userBatchDao")
public class UserBatchDaoImpl implements UserBatchDao {

	/** 注入批处理的SqlSessionTemplate */
	@Qualifier("batchSqlSession")
	@Autowired
	private SqlSessionTemplate batchSqlSession;

	@Override
	public void batch_account(List<Account> accounts) {
		SqlSession sqlSession = batchSqlSession.getSqlSessionFactory().openSession(ExecutorType.BATCH);
		AccountDao accountDao = sqlSession.getMapper(AccountDao.class);
		for (Account account : accounts) {
			accountDao.addUser(account);
		}
		sqlSession.flushStatements();
		sqlSession.commit();
		sqlSession.close();
	}
}
